<?php
/**
 * +--------------------------------------------------------+
 * @Created by PhpStorm.
 * @Category Store.php
 * @Depiction:
 * Author: hwy
 * Date: 2020/9/30  16:46
 * +--------------------------------------------------------+
 */

namespace App\Http\Requests\Admin;


use App\Http\Requests\BaseRequestsPost;
use App\Rules\AlphaNumRule;

class Store extends BaseRequestsPost
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name'     => ['required', 'unique:admins,name', new AlphaNumRule()],
            'password' => 'required|between:6,18',
            'role_id'  => 'required',
        ];
    }

    /**
     * 定义字段名中文
     *
     * @return array
     */
    public function attributes()
    {
        return [
            'name'     => '用户名',
            'password' => '密码',
            'role_id'  => '角色',
        ];
    }

    public function messages()
    {
        return [
            'name.required'     => '用户名不能为空！',
            'name.unique'       => '用户名已存在！',
            'password.required' => '密码不能为空！',
            'password.between'  => '密码长度在6-18个字符之间！',
            'role_id.required'  => '角色不能为空！',
        ];
    }
}
